const ThemeObservable = require('../observable/ThemeObservable')

export default {

    /* ------------------------- 主题相关 ------------------------- */
    THEME: {
        DARK: "theme-dark",
        LIGHT: "theme-light",
    },

    saveTheme(theme) {
        if (!theme) return;
        localStorage.setItem("theme", theme)
    },

    getTheme() {
        return localStorage.getItem("theme") || this.THEME.LIGHT;
    },

    switchTheme(theme) {
        if (!theme) theme = this.getTheme();
        document.querySelector("body").className = theme
        this.saveTheme(theme);
        if (theme) ThemeObservable.default.dispatchThemeSwitchListener(theme)
    },


} 